//
//  NSError+Ex.swift
//  NetProject
//
//  Created by EDY on 2021/11/3.
//

import Foundation
import UIKit

public extension Error {
    
    func message(code:Int) -> String{
        var message = ""
        switch code {
        case -1 :
            message = "未知"//          NSURLErrorUnknown
        case -999 ://
            message = "网络取消"//       NSURLErrorCancelled
        case -1000 ://
            message = "错误URL"//       NSURLErrorBadURL
        case -1001 ://
            message = "请求超时"//       NSURLErrorTimedOut
        case -1002 ://
            message = "不支持的URL"//       NSURLErrorUnsupportedURL
        case -1003 ://
            message = "找不到主机"//       NSURLErrorCannotFindHost
        case -1004 ://
            message = "无法连接到主机"//       NSURLErrorCannotConnectToHost
        case -1103 ://
            message = "数据长度超过最大值"//       NSURLErrorDataLengthExceedsMaximum
        case -1005 ://
            message = "网络连接丢失"//       NSURLErrorNetworkConnectionLost
        case -1006 ://
            message = "DNS查询失败"//       NSURLErrorDNSLookupFailed
        case -1007 ://
            message = "HTTP重定向太多"//       NSURLErrorHTTPTooManyRedirects
        case -1008 ://
            message = "资源不可用"//       NSURLErrorResourceUnavailable
        case -1009 ://
            message = "未连接到互联网的NSURL错误"//       NSURLErrorNotConnectedToInternet
        case -1010 ://
            message = "重定向到不存在的位置"//       NSURLErrorRedirectToNonExistentLocation
        case -1011 ://
            message = "服务器响应错误"//       NSURLErrorBadServerResponse
        case -1012 ://
            message = "用户取消身份验证"//       NSURLErrorUserCancelledAuthentication
        case -1013 ://
            message = "需要身份验证"//       NSURLErrorUserAuthenticationRequired
        case -1014 ://
            message = "0字节资源"//       NSURLErrorZeroByteResource
        case -1015 ://
            message = "无法解码原始数据"//       NSURLErrorCannotDecodeRawData
        case -1016 ://
            message = "无法解码内容数据"//       NSURLErrorCannotDecodeContentData
        case -1017 ://
            message = "无法解析响应"//       NSURLErrorCannotParseResponse
        case -1100 ://
            message = "文件不存在"//       NSURLErrorFileDoesNotExist
        case -1101 ://
            message = "当前访问的是文件目录"//       NSURLErrorFileIsDirectory
        case -1102 ://
            message = "没有权限读取文件"//       NSURLErrorNoPermissionsToReadFile
        case -1200 ://
            message = "安全连接失败"//       NSURLErrorSecureConnectionFailed
        case -1201 ://
            message = "服务器证书有错误日期"//       NSURLErrorServerCertificateHasBadDate
        case -1202 ://
            message = "服务器证书不可信"//       NSURLErrorServerCertificateUntrusted
        case -1203 ://
            message = "服务器证书有未知的根"//       NSURLErrorServerCertificateHasUnknownRoot
        case -1204 ://
            message = "服务器证书无效"//       NSURLErrorServerCertificateNotYetValid
        case -1205 ://
            message = "客户端证书拒绝"//       NSURLErrorClientCertificateRejected
        case -1206 ://
            message = "需要客户端证书"//       NSURLErrorClientCertificateRequired
        case -2000 ://
            message = "无法从网络加载"//       NSURLErrorCannotLoadFromNetwork
        case -3000 ://
            message = "无法创建文件"//       NSURLErrorCannotCreateFile
        case -3001 ://
            message = "无法打开文件"//       NSURLErrorCannotOpenFile
        case -3002 ://
            message = "无法关闭文件"//       NSURLErrorCannotCloseFile
        case -3003 ://
            message = "无法写入文件"//       NSURLErrorCannotWriteToFile
        case -3004 ://
            message = "无法删除文件"//       NSURLErrorCannotRemoveFile
        case -3005 ://
            message = "无法移动文件"//       NSURLErrorCannotMoveFile
        case -3006 ://
            message = "下载解码失败中流"//       NSURLErrorDownloadDecodingFailedMidStream
        case -3007 ://
            message = "下载解码失败"//       NSURLErrorDownloadDecodingFailedToComplete
            
            
        default:
            message = ""
        }
        return message
    }
    
    
       
}
